//
//  RichTextTableViewCell.m
//  NLProjectFrameworkDemo
//
//  Created by iosdeveloper on 2020/8/19.
//  Copyright © 2020 yj_zhang. All rights reserved.
//

#import "RichTextTableViewCell.h"

@implementation RichTextTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpView];
    }
    return self;
}

-(void)setUpView{
      [super setUpView];
      // self.contentLabel.hidden=YES;//隐藏基类里面的文字
    
//        UITextView *textView = [UITextView new];
//        textView.backgroundColor = [UIColor whiteColor];
//        self.textView =textView;
//        textView.userInteractionEnabled=NO;
//        textView.scrollEnabled=NO;
//        [self.bgView addSubview:textView];
    
   

}

-(void)reloadCellModel:(MantisCellBaseModel*)data{
    [super reloadCellModel:data];
    NSString*imgStr=data.imgUrl;
    if (imgStr.length>0) {
        [self.avaterView setImageWithURL:[NSURL URLWithString:imgStr] placeholder:[UIImage imageNamed:@"chat_visitor_avater"]];
    }
   
    MantisRichTextModel*newData=( MantisRichTextModel*)data;
    self.contentLabel.attributedText=newData.richStr;
  
    
    CGFloat bgWidth =newData.contentSize.width+20;
    CGFloat bgHeight =newData.contentSize.height+20;
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.avaterView.mas_right).offset(adaptWidth750(20));
        make.top.equalTo(self.avaterView);
        make.width.mas_equalTo(bgWidth);
        make.height.mas_equalTo(bgHeight);
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
        make.bottom.mas_equalTo(-10);
        make.right.mas_equalTo(-10);
      }];
    
    CGSize labelSize =CGSizeMake(bgWidth, bgHeight);
    [self setThreeCorner:labelSize bgView:self.bgView];
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
